package com.tnmi.base.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @version 1.0
 * @Classname SuperEntity
 * @Description TODO
 * @Date 2023/7/1 22:55
 * @Created by tnmi
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SuperEntity<T> implements Serializable,Cloneable {

    public static final String FIELD_ID = "id";
    public static final String CREATE_TIME = "createTime";
    public static final String CREATE_USER = "createUser";

    @TableId(value = "id",type = IdType.AUTO)
    @ApiModelProperty(value = "主键")
    @NotNull(message = "id不能为空", groups=SuperEntity.Update.class)
    protected T id;
    @TableField(value = "create_time", fill= FieldFill.INSERT)
    @ApiModelProperty(value = "主键")
    protected LocalDateTime createTime;
    @TableField(value = "create_user",fill= FieldFill.INSERT)
    @ApiModelProperty(value = "主键")
    protected T createUser;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public interface Save extends Default{

    }

    public interface Update extends Default{

    }
}
